/*
day90
2019.11.26
*/
#include<vector>
#include<queue>
using namespace std;

struct TreeNode {
	struct TreeNode *left;
	struct TreeNode *right;
	int val;
};


class Solution {
public:
    vector<int> largestValues(TreeNode* root) 
	{
        vector<int> vec;
        
        if(!root) return vec;
		 
        queue<struct TreeNode *> que;
        que.push(root);
        TreeNode *cur;
        while(!que.empty())
        {
        	int num=que.size();
        	int max=que.front()->val;
        	for(int i=0;i<num;i++)
        	{
        		cur=que.front();
        		if(cur->val>max) max=cur->val;
        		que.pop();
        		if(cur->left) que.push(cur->left);
        		if(cur->right) que.push(cur->right);
			}
			vec.push_back(max);
		}
		return vec;
    }
};


int main()
{
	return 0;
}
